<?php
class ModelCatalogNewsletter extends Model {
	public function addNewsletter($data) {
      	$this->db->query("INSERT INTO " . DB_PREFIX . "newsletter SET name = '" . $this->db->escape($data['name']) . "', email = '" . $this->db->escape($data['email']) . "'");       	
	}
	
	public function getNewsletterByEmail($email) {
		$query = $this->db->query("(SELECT DISTINCT newsletter_id, email FROM " . DB_PREFIX . "newsletter WHERE email = '" . $this->db->escape($email) . "') UNION (SELECT DISTINCT customer_id AS newsletter_id, email FROM " . DB_PREFIX . "customer WHERE email = '" . $this->db->escape($email) . "')");
		
		return $query->row;
	}
		
}
?>